import { NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';

import Detail from './Detail';
import Efamily from './Efamily';
import SwiperPicture from './Swiper';
import TabBar from './TabBar';
import { useInstall } from '../context';

const Stack = createNativeStackNavigator();
// 在App里面拿不到isInstall,但是Provider提供了，现在可以使用了


const Container = () => {
    // 用useInstall()拿到value里面的所有的状态,是一个对象，需要解构
    const { isInstall } = useInstall();
    return (
      <NavigationContainer>
        <Stack.Navigator>
        {
          isInstall?
          <Stack.Screen
            options={{ headerShown: false }}
            name='Root' component={TabBar} />
          :
          <Stack.Screen
            options={{
              headerShown: false
            }}
            name='Swiper' component={SwiperPicture} />
          }
          <Stack.Screen name='Detail' component={Detail} />
          <Stack.Screen name='Efamily' component={Efamily}
          />
        </Stack.Navigator>
      </NavigationContainer>
    )
  }
  export default Container;